# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=libsass
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.6.6
pkgrel=1
pkgdesc="C implementation of Sass CSS preprocessor (library) (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://sass-lang.com/libsass"
msys2_repository_url="https://github.com/sass/libsass"
msys2_references=(
  "cpe: cpe:/a:libsass:libsass"
  "cpe: cpe:/a:sass-lang:libsass"
)
license=("spdx:MIT")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/sass/$_realname/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('11f0bb3709a4f20285507419d7618f3877a425c0131ea8df40fe6196129df15d')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  autoreconf -vfi
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make DESTDIR="${pkgdir}" install

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
